package advance.homework;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author Raymond
 * @create 2025/4/23 10:30
 */
public class MyArraysExc {
    public static void main(String[] args) {
        Book[] books = new Book[4];
        books[0] = new Book("A", 100);
        books[1] = new Book("B", 90);
        books[2] = new Book("C", 5);
        books[3] = new Book("D", 300);
        //重写compare对该数组进行排序 从大到小
        Arrays.sort(books, new Comparator<Book>() {
            @Override
            public int compare(Book o1, Book o2) {
                return o2.getPrice()-o1.getPrice();
            }
        });
        System.out.println("Arrays.toString(books) = " + Arrays.toString(books));
    }
}
